﻿Public Class ColorNumberArgHandler
    Implements IArgHandler

    Public Function ValidateArgument(library As RawLibrary, obj As RawObject, argument As ArgumentDefinition, value As String) As String Implements IArgHandler.ValidateArgument
        Dim val As Integer = 0
        If Not Integer.TryParse(value, val) Then
            Return "Value must be a valid color number."
        End If

        If val < 0 OrElse val > 15 Then
            Return "value must be a valid color number."
        End If

        If argument.TypeData = "high" Then
            If val < 8 Then
                Return "Value must be from the ""Bright"" color list."
            End If
        End If

        If argument.TypeData = "low" Then
            If val > 7 Then
                Return "Value must be from the ""Dim"" color list."
            End If
        End If


        Return Nothing
    End Function

    Public Function ValidateTypeData(typeData As String) As Boolean Implements IArgHandler.ValidateTypeData
        Select Case typeData
            Case "", "all", "high", "low"
                Return True
            Case Else
                Return False
        End Select
    End Function

    Public Function GetValues(obj As RawObject, argument As ArgumentDefinition) As System.Collections.Generic.IEnumerable(Of String) Implements IArgHandler.GetValues
        Return New List(Of String)
    End Function

    Public ReadOnly Property TypeDataFormat As String Implements IArgHandler.TypeDataFormat
        Get
            Return "[all|high|low]"
        End Get
    End Property

    Public ReadOnly Property DefaultTypeData As String Implements IArgHandler.DefaultTypeData
        Get
            Return ""
        End Get
    End Property

    Public ReadOnly Property DefaultValue(library As RawLibrary, obj As RawObject, argument As ArgumentDefinition) As String Implements IArgHandler.DefaultValue
        Get
            Return "0"
        End Get
    End Property

    Public Function Parse(argParts As System.Collections.Generic.IEnumerator(Of String), arg As ArgumentDefinition) As String Implements IArgHandler.Parse
        Return argParts.Current
    End Function

    Public Function GetNavList(library As RawLibrary, obj As RawObject, argument As ArgumentDefinition, value As String) As IEnumerable(Of NavPoint) Implements IArgHandler.GetNavList
        Return Nothing
    End Function
End Class
